package com.nstar.helloworld.view
{
	import mx.containers.VBox;
	import mx.containers.Panel;
	import flash.events.MouseEvent;
	import mx.effects.Glow;
	import mx.controls.LinkButton;
	import mx.events.FlexEvent;
	import flash.events.Event;
	import com.nstar.helloworld.events.UserThumbEvent;

	public class UserInfoClass extends VBox
	{
		[Bindable]
		public var item:Object;
		
		public var btnDesc:LinkButton;
		public var btnTile:LinkButton;
		public var btnDelete:LinkButton;
		public var btnEdit:LinkButton;
		
		public function UserInfoClass()
		{
			//TODO: implement function
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,init);
		}
		
		function init(event:FlexEvent):void{
			btnDesc.addEventListener(MouseEvent.CLICK,descHandler);
			btnTile.addEventListener(MouseEvent.CLICK,tileHandler);
			this.addEventListener(MouseEvent.CLICK,clickHandler);
			this.addEventListener(MouseEvent.ROLL_OVER,rolloverHandler);
			this.addEventListener(MouseEvent.ROLL_OUT,rolloutHandler);
		}
		
		//显示详细信息
		function descHandler(event:MouseEvent):void{
			this.parent.dispatchEvent(new Event("userDesc"));
		}
		//返回到列表
		function tileHandler(event:MouseEvent):void{
			this.parent.dispatchEvent(new Event("tile"));
		}		
		//单击事件处理
		function clickHandler(event:MouseEvent):void{
			this.dispatchEvent(new UserThumbEvent(UserThumbEvent.DETAILS,item));
		}
		//鼠标经过时的样式
		function rolloverHandler(event:MouseEvent):void{
			setDefault(true);
		}
		//鼠标离开后的样式
		function rolloutHandler(event:MouseEvent):void{
			setDefault(false);
		}
		
		//设置组件缺省属性
		function setDefault(value:Boolean):void{
			this.setStyle("dropShadowEnabled",value);
			if (value){
				this.setStyle("borderStyle","solid");	
			}else{
				this.setStyle("borderStyle","none");
			}
			
			btnDesc.visible = value;
			btnEdit.visible = value;
			btnTile.visible = value;
			btnDelete.visible = value;
			
		}
	}
}